package com.jshop.seckill.web.controller;

import com.jshop.seckill.http.PageResult;
import com.jshop.seckill.http.HttpResult;
import com.jshop.seckill.web.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 * @Author yaxiongliu
 * @CreateDate
 * @Version 1.0
 * @Description //TODO 商品
 */
@RestController
@RequestMapping("/seckill")
public class GoodsController {

    @Autowired
    GoodsService goodsService;
    /**
     * 查询商品详情
     * http://localhost:9000/seckill/goods/detail/19
     */
    @GetMapping("/goods/detail/{pid}")
    public HttpResult findDetail(@PathVariable String pid) {
        HttpResult result = goodsService.findDetail(pid);
        return result;
    }

    /**
     * 分页查询商品列表
     * http://localhost:9000/seckill/goods/detail/19
     */
    @GetMapping("goods/list/{pageNo}/{pageSize}")
    PageResult queryGoodList(@PathVariable("pageNo")Integer pageNo, @PathVariable("pageSize")Integer pageSize){
        //传入分页参数查询当前页结果列表
        PageResult result=goodsService.queryGoodList(pageNo,pageSize);

        return result;
    }
}
